<CFIF ISDEFINED("url.notroute")>
	<script>
		alert('The form is empty.');
	</script>
</CFIF>
<CFSET sDESCRIPTION="">
<CFSET sDateFrom="">
<CFSET sDateTO="">
<CFPARAM NAME="appno" DEfAULT="">
<CFPARAM NAME="encappno" DEfAULT="">
<CFPARAM NAME="encAppActive" DEfAULT="">
<CFMODULE TEMPLATE = "#client.common_path#cfm_checkuserrecords.cfm" USERTABLE = "ECRTWORKSCHED"
		USERFIELD = "USERGRPID_FK" RECORDFIELD = "WSCODE_FK" BOOLEANFIELDS="PERMSCHED,TEMPSCHED,SUBTEMPSCHED,ISPOST" RECORDID="#sID#">
	
<CFINCLUDE TEMPLATE="../common/popdate.cfm">
<SCRIPT language="JavaScript1.2">
	function checkMe(lblLbl) {
		var theLbl = document.getElementById("id" + lblLbl);
		var theId = eval("document.frmSched.chk" + lblLbl);
		if (theId[0]){
			for (i = 0; i < theId.length; ++ i) {
				theId[i].checked = theLbl.checked;
			}
		} else {
			theId.checked = theLbl.checked;
		}
	}
	function ShowCalendar(FormName, FieldName) {
			quickpopdate(FormName, FieldName)
	}
	function verifydelete(sMessage,sAlert,sSked) {
		var x="false";
		var y="false";
		var itemvalue="";
		for(var i=0; i <= (document.frmSched.chkPID.length - 1); i++){
			if (document.frmSched.chkPID[i].checked){
				itemvalue = itemvalue + document.frmSched.chkPID[i].value + "\n";
				x="true";
			}		
		}
		if (x=="true"){
			if(sSked != ''){
				for(var i=0; i <= (document.frmSched.chkMaster.length - 1); i++){
					if (document.frmSched.chkMaster[i].checked){
						y="true";
					}
				}
			}
			else{
				y="true";
			}
		}
		
		
		if (x=="false")
			{
			alert (sAlert);
			return false;
			}
		else if (y=="false")
			{
			alert (sSked);
			return false;
			}
		else 
			{
			return confirmThis(sMessage + "\n" + itemvalue);
			return true;
			}
	}
	<CFOUTPUT>
	function ShowLookupSched(level, tblname, frmfldcode, formname, fld2disp, fldcode, frmflddesc, flddesc) {
		open("../common/poplookup.cfm" +
		"?tl=" + escape(level) +
		"&tn=" + escape(tblname) +
		"&fn=" + escape(frmfldcode) +
		"&frm=" + escape(formname) +
		"&fldprop=" + escape(fld2disp) +
		"&fldfn=" + escape(fldcode) +
		"&desc=" + escape(frmflddesc) +
		"&flddesc=" + escape(flddesc),
		"LookupWindow", "width=660,height=330,ScrollBars=Yes,Resizable=Yes");
	}
	function ShowLookup(level, tblname, frmfldcode, formname, fld2disp, fldcode, frmflddesc, flddesc, fldFilter, fldVal) {
		open("#client.common_path#poplookup.cfm" +
		"?tl=" + escape(level) +
		"&tn=" + escape(tblname) +
		"&fn=" + escape(frmfldcode) +
		"&frm=" + escape(formname) +
		"&fldprop=" + escape(fld2disp) +
		"&fldfn=" + escape(fldcode) +
		"&desc=" + escape(frmflddesc) +
		"&flddesc=" + escape(flddesc) +
		"&fldFilter=" + escape(fldFilter) +
		"&fldVal=" + escape(fldVal),
		"LookupWindow", "width=660,height=330,ScrollBars=Yes,Resizable=Yes");
	}
	</CFOUTPUT>
</SCRIPT>
<SCRIPT language="javascript">
	function CheckField() {
		var lReturn=true
		with (document.frmSched) {
			if (btnBackAction.TAG==0) {
				if (edtDESCRIPTION.value == "") {
					alert("Please do not leave the Description field blank.")
					edtDESCRIPTION.focus()
					lReturn=false
				} else {
					lReturn=true
				}
			}
		}
	return (lReturn)
	}
</SCRIPT>
<CFIF sWarn NEQ "">
	<!--- wow mali! --->
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="There was a problem!">
	<CFOUTPUT>
	<FONT COLOR="##FF0000"><B>#sWarn#</B></FONT><BR>
	</CFOUTPUT>
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
</CFIF>
<CFIF sMess NEQ "">
	<CFOUTPUT>
		<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="Information">
		<BR><B>#sMess#</B><BR>
		<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
	</CFOUTPUT>
</CFIF>
<CFSET nFolder=1>
<CFIF isDefined("url.currfolder")>
	<CFSET nFolder=DECRYPT(url.currfolder,client.ek)>
</CFIF>
<CFSET nFolderEnc=URLEncodedFormat(encrypt(nFolder,client.ek))>
<CFSET isRouteActive=FALSE>
<CFIF NOT ISDEFINED("FORM.btnISADD")>
	<CFQUERY NAME="getData" DATASOURCE="#client.company_dsn#">
		SELECT * FROM CINWORKSCHED
		WHERE WSCODE_FK = '#sID#'
		AND WSNUMBER='#wsIDnum#'
	</CFQUERY>
	<CFSET sDESCRIPTION=getData.DESCRIPTION>
	<CFSET sDateFrom=dateformat(getData.STARTDATE,"mm/dd/yyyy")>
	<CFSET sDateTO=dateformat(getData.ENDDATE,"mm/dd/yyyy")>
	<CFIF getData.APPROVED EQ "S" OR getData.APPROVED EQ "N" OR getData.APPROVED EQ "Y" AND WSACTION NEQ "COPY" >
		<CFSET isRouteActive=true>
	</CFIF>
</CFIF>
<CFIF wsIDnum EQ "">
	<CFQUERY DATASOURCE="#client.global_dsn#" NAME="qryGSTAUTOGENFIELD">
		SELECT *
		FROM GSTAUTOGENFIELD
		WHERE TABLENAME = 'CINWORKSCHED' AND
			  FIELDNAME = 'WSNUMBER'
	</CFQUERY>
	<CFIF qryGSTAUTOGENFIELD.recordcount NEQ 0>
		<CFMODULE TEMPLATE="#client.common_path#cfm_autogen.cfm"
		SEEDKEY="#qryGSTAUTOGENFIELD.SEEDKEY#"
		CODELENGTH="#qryGSTAUTOGENFIELD.CODELENGTH#"
		COLUMNNAME="#qryGSTAUTOGENFIELD.FIELDNAME#"
		TABLENAME_FK="#qryGSTAUTOGENFIELD.TABLENAME#"
		DATASOURCE="#client.company_dsn#">
		<CFSET wsIDnum=AUTOGENVALUE>
	</CFIF>
</CFIF>
<CFIF vPosted EQ "Yes" OR isRouteActive OR ISDEFINED("URL.VIEW") OR WSACTION EQ "COPY">
	<CFSET isEnabled = "FALSE">
	<CFSET sCanUpdate="DISABLED">
<CFELSE>
	<CFSET isEnabled = "TRUE">
	<CFSET sCanUpdate="">
</CFIF>
<CFQUERY NAME="getEmpList" DATASOURCE="#client.company_dsn#">
	SELECT DISTINCT PERSONNELIDNO FROM CINWSSUBSKEDPOOL
	WHERE WSNUMBER_FK = '#wsIDnum#'
</CFQUERY>
<CFSET nCounter=0>
<CFSET appidENC= "">
<CFOUTPUT QUERY="getEmpList">
	<CFSET nCounter=nCounter + 1>
	<CFQUERY NAME="QUERYVIEW" DATASOURCE="#client.company_dsn#">
		SELECT
			PERSONNELIDNO, LASTNAME, FIRSTNAME, MIDDLENAME
		FROM CMFPA
		WHERE  PERSONNELIDNO ='#getEmpList.PERSONNELIDNO#'
	</CFQUERY>
	<CFSET encappno= urlEncodedFormat(encrypt(getEmpList.PERSONNELIDNO, client.ek))>
	<CFIF (NOT ISDEFINED("appno") or appno eq "" OR ISDEFINED("URL.deleteemp")) AND nCounter EQ 1>
		<CFSET appno=getEmpList.PERSONNELIDNO>
	</CFIF>
</CFOUTPUT>

<CFQUERY NAME="qryGeteForms" DATASOURCE="#client.company_dsn#">
	SELECT PROCESSCODE FROM ECRGFORMS WHERE FORMCODE='#GETECRG.FORMCODE#'
</CFQUERY>
<CFOUTPUT>
	<FORM ACTION="index.cfm?id=#sIDUrlEnc#&wsnum=#wsIDnumEnc##allURL#" METHOD="post" NAME="frmSched" ONSUBMIT="return CheckField();" >
</CFOUTPUT>
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="eWorkSked General Information">
		<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">
			<CFOUTPUT>
			<TR>
				<TD COLSPAN="3">
					<CFIF isEnabled  OR WSACTION EQ "COPY">
						<INPUT CLASS="bitbtn" TYPE="submit" NAME="btnSaveAction" VALUE=
							<CFIF IsDefined("form.btnISADD")> "Save"
							<CFELSEIF WSACTION EQ "COPY"> "Replicate"
							<CFELSE> "Update"
							</CFIF>  <CFIF WSACTION NEQ "COPY"> #sCanUpdate#</CFIF>
						>
					</CFIF>
					<INPUT CLASS="bitbtn" TYPE="submit" NAME="btnBackAction" VALUE="Back">
					<CFIF fieldISPOST EQ "Y" AND NOT ISDEFINED("FORM.btnISADD") AND isEnabled>
						<INPUT #sCanUpdate# CLASS="bitbtn" TYPE="submit" VALUE=
							<CFIF qryGeteForms.PROCESSCODE NEQ "" and qryGeteForms.PROCESSCODE NEQ "|null|"> "Route eWorksked"  NAME="btnRoute"
							<CFELSE> "Post eWorksked"  NAME="btnPost"
							</CFIF> <CFIF WSACTION NEQ "COPY"> #sCanUpdate#</CFIF>
						>
					</CFIF>
					
					<HR>
				</TD>
			</TR>
			</CFOUTPUT>
			<CFOUTPUT>
				<INPUT TYPE="Hidden" NAME="hidWSNUM" value="#wsIDnum#">
				<TR>
					<TD WIDTH="10%">Document No.:</TD>
					<TD WIDTH="1%">*</TD>
					<TD><INPUT TYPE="TEXT" NAME="edtDOCNUMBER" VALUE="#wsIDnum#" MAXLENGTH="20" SIZE="25" <CFIF wsIDnum NEQ "">READONLY</CFIF>></TD>
				</TR>
				<TR>
					<TD WIDTH="10%">Description:</TD>
					<TD WIDTH="1%">*</TD>
					<TD><INPUT TYPE="TEXT" NAME="edtDESCRIPTION" VALUE="#sDESCRIPTION#" MAXLENGTH="50" SIZE="70" <CFIF WSACTION NEQ "COPY"> #sCanUpdate#</CFIF>></TD>
				</TR>
				<TR>
					<TD WIDTH = "10%">Start Date:</TD>
					<TD WIDTH = "1%">*</TD>
					<TD>
						<INPUT TYPE="TEXT" NAME="edtDateFrom" VALUE="#sDateFrom#" SIZE="10" <CFIF WSACTION NEQ "COPY"> #sCanUpdate#</CFIF>>
						<CFIF isEnabled OR WSACTION EQ "COPY">
							<A HREF="javascript:quickpopdate('frmSched','edtDateFrom');"><IMG SRC="#client.icon_path#calendar.gif" BORDER="0" ALT="View Calendar" ALIGN="bottom"></A>
						<CFELSE>
							<IMG SRC="#client.icon_path#calendar.gif" BORDER="0" ALT="View Calendar" ALIGN="bottom">
						</CFIF>
					</TD>	
				</TR>
				<TR>
					<TD>End Date:</TD>
					<TD>*</TD>
					<TD>
						<INPUT TYPE="TEXT" NAME="edtDateTo" VALUE="#sDateTo#" SIZE="10" <CFIF WSACTION NEQ "COPY"> #sCanUpdate#</CFIF>>
						<CFIF isEnabled OR WSACTION EQ "COPY">
							<A HREF="javascript:quickpopdate('frmSched','edtDateTo');"><IMG SRC="#client.icon_path#calendar.gif" BORDER="0" ALT="View Calendar" ALIGN="bottom"></A>
						<CFELSE>
							<IMG SRC="#client.icon_path#calendar.gif" BORDER="0" ALT="View Calendar" ALIGN="bottom">
						</CFIF>
					</TD>	
				</TR>
			</CFOUTPUT>
		</TABLE>
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="Employee List">
		<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 WIDTH="100%">
			<CFOUTPUT>
				<TR>
					<TD colspan=3>
					   <CFIF isEnabled>
						<INPUT TYPE="SUBMIT" NAME="btnAddEmployee" VALUE = "Add Employees" CLASS="bitbtn" ONCLICK="return confirmThis('Save record to add employees?')">&nbsp;
						<INPUT TYPE="SUBMIT" NAME="btnDeleteEmployee" VALUE = "Delete Selected Employees" CLASS="bitbtn" ONCLICK="return verifydelete('Delete selected employees?','Please select an employee to delete.','')">&nbsp;
					   </CFIF>
					</TD>
				</TR>
				<TR BGCOLOR="#client.color_tblhead#" ALIGN="CENTER">
					<CFIF getEmpList.recordcount GT 0 AND isEnabled>
						<TD CLASS="BOLDWHITE">
							<INPUT TYPE="checkbox" NAME="lblPID" id="idPID" label="" onClick="javascript:checkMe('PID')">
						</TD>
					</CFIF>
					<TD CLASS="boldwhite">Personnel ID No</TD>
					<TD CLASS="boldwhite">Last Name</TD>
					<TD CLASS="boldwhite">First Name</TD>
					<TD CLASS="boldwhite">Middle Name</TD>
				</TR>
			</CFOUTPUT>
			<CFIF getEmpList.recordcount GT 0>
				<INPUT TYPE="hidden" NAME="chkPID" VALUE="">
				<CFSET nCounter=0>
				<CFOUTPUT QUERY="getEmpList">
					<CFSET nCounter=nCounter + 1>
					<CFQUERY NAME="QUERYVIEW" DATASOURCE="#client.company_dsn#">
						SELECT
							PERSONNELIDNO, LASTNAME, FIRSTNAME, MIDDLENAME
						FROM CMFPA
						WHERE  PERSONNELIDNO ='#getEmpList.PERSONNELIDNO#'
					</CFQUERY>
					<CFIF (NOT ISDEFINED("appno") or appno eq "" OR ISDEFINED("URL.deleteemp") OR (ISDEFINED("FORM.chkPID") AND LISTLEN(FORM.chkPID) EQ 1))  AND nCounter EQ 1>
						<CFIF ISDEFINED("FORM.chkPID") AND LISTLEN(FORM.chkPID) EQ 1>
							<CFSET appno=ListGetAt(FORM.chkPID, 1, "-")>
						<CFELSE>
							<CFSET appno=getEmpList.PERSONNELIDNO>
						</CFIF>
					</CFIF>
					<TR BGCOLOR="#IIf(CurrentRow Mod 2, "client.color_tblset2", "client.color_tblset1")#" VALIGN="top">
						<CFIF isEnabled>
							<TD NOWRAP CLASS="regular11" WIDTH="100"><CENTER>&nbsp;
								<INPUT TYPE="checkbox" NAME="chkPID" VALUE="#QUERYVIEW.PERSONNELIDNO#- #QUERYVIEW.LASTNAME# #QUERYVIEW.FIRSTNAME#" <CFIF appno EQ getEmpList.PERSONNELIDNO>CHECKED  </CFIF>>
							</TD>
						</CFIF>
						<TD>
							
							<CFIF appno NEQ getEmpList.PERSONNELIDNO>
								<CFSET encappno= urlEncodedFormat(encrypt(getEmpList.PERSONNELIDNO, client.ek))>
								<A HREF="#getfilefrompath(getbasetemplatepath())#?id=#sIDUrlEnc#&wsnum=#wsIDnumEnc#&appNo=#encappno#&currfolder=#nFolderEnc#" CLASS="regular11">#QUERYVIEW.PERSONNELIDNO#</A>&nbsp;
							<CFELSE>
								<CFSET encAppActive=urlEncodedFormat(encrypt(getEmpList.PERSONNELIDNO, client.ek))>
								#QUERYVIEW.PERSONNELIDNO#
							</CFIF>
						</TD>
						<TD>#QUERYVIEW.LASTNAME#</TD>
						<TD>#QUERYVIEW.FIRSTNAME#</TD>
						<TD>#QUERYVIEW.MIDDLENAME#</TD>
					</TR>
				</CFOUTPUT>
			<CFELSE>
				<tr><td ALIGN="CENTER" class="bold" WIDTH=250 COLSPAN = 5>No records found.</td></tr>
			</CFIF>
			<CFOUTPUT>
				<TR BGCOLOR="#client.color_tblfoot#">
					<TD COLSPAN=6 CLASS="boldwhite" HEIGHT=18>&nbsp;#getEmpList.RecordCount# records found.</TD>
				</TR>
			</CFOUTPUT>
		</TABLE>
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
	<CFIF getEmpList.recordcount GT 0>
		<TABLE cellpadding="1" cellspacing="0" bgcolor="#EFEFEF" class="BorderOnly" width="100%">
			<tr><td colspan="3" height="1px"></td></tr>
			<tr>
				<td width="1px"></td>
				<td>
					<CFSET folderLISTFOLDERNAME="Specific Date Range">
					<CFSET folderLISTFOLDERINCLUDE="gui_daterange">
					<CFIF fieldPERMSCHED EQ "Y">
						<CFSET folderLISTFOLDERNAME=LISTAPPEND(folderLISTFOLDERNAME,"Permanent Schedule")>
						<CFSET folderLISTFOLDERINCLUDE=LISTAPPEND(folderLISTFOLDERINCLUDE,"gui_permsched")>
					</CFIF>
					<CFIF fieldTEMPSCHED EQ "Y">
						<CFSET folderLISTFOLDERNAME=LISTAPPEND(folderLISTFOLDERNAME,"Temporary Schedule")>
						<CFSET folderLISTFOLDERINCLUDE=LISTAPPEND(folderLISTFOLDERINCLUDE,"gui_tempsched")>
					</CFIF>
					<CFIF fieldSUBTEMPSCHED EQ "Y">
						<CFSET folderLISTFOLDERNAME=LISTAPPEND(folderLISTFOLDERNAME,"Sub-Temporary Schedule")>
						<CFSET folderLISTFOLDERINCLUDE=LISTAPPEND(folderLISTFOLDERINCLUDE,"gui_subtempsched")>
					</CFIF>
					<!---<CFSET folderLISTFOLDERNAME="Specific Date Range,Permanent Schedule,Temporary Schedule">
					<CFSET folderLISTFOLDERINCLUDE="gui_daterange,gui_permsched,gui_tempsched">--->
					<CFIF folderLISTFOLDERNAME NEQ "" AND folderLISTFOLDERINCLUDE NEQ "">
						<CFSET folderEXCESS="30%">
						<CFSET folderOPENFOLDER="1">
						<CFSET folderTAGHEIGHT="23px">
						<CFSET folderINNERWIDTH="99%">
						<CFSET folderINNERTRBLMARGIN="2px 1px 2px 3px">
						<CFSET folderBASEPATH="../wsmain/">
		
						<CFINCLUDE TEMPLATE="../common/Folder.cfm">
					</CFIF>
				</td>
			<td width="1px"></td>
			</tr>
		</TABLE>
	</CFIF>
</FORM>
